const question = require("../models/question")

var express = require('express');
var router = express.Router();

const formidable = require('formidable');

//返回图片
router.post('/', (req, res, next) => {
    var form = new formidable.IncomingForm();
    form.parse(req, function (err, fields, files) {
        if (err) {
            res.json({ 'state': false })
        } else {
            question.create({
                point_id: fields.point_id,
                position: fields.position,
                seq: fields.seq,
                UUID: fields.UUID,
                question: fields.question,
                type: fields.type,
                items: fields.items,
                answer: fields.answer,
                illustrationContent: fields.illustrationContent,
                bloom: fields.bloom
            }, (error, doc) => {
                if (error) {
                    res.json({ 'state': false, 'msg': error });
                } else {
                    res.json({ 'state': true, 'msg': "ok" });
                }
            })
        }

    });

});

module.exports = router;